//
//  AccountCell.m
//  MyBank
//
//  Created by 崔宝印 on 2017/8/3.
//  Copyright © 2017年 Koolearn. All rights reserved.
//

#import "AccountCell.h"
#import "CoreDataHelper.h"

@implementation AccountCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)resetSubviewWithDataModel:(id)model
{
    if ([model isKindOfClass:[CreditCard class]])
    {
        CreditCard *card = (CreditCard *)model;
        self.tagImageView.image = [UIImage imageNamed:card.bankName];
        self.accountNameLabel.text = card.bankName;
        
        float debet = card.availableLimit - card.temporaryLimit;
        self.accountBalanceLabel.text  = [NSString stringWithFormat:@"%.2f",debet];
        if (debet < 0)
        {
            self.accountBalanceLabel.textColor = [UIColor redColor];
        }
        else
        {
            self.accountBalanceLabel.textColor = [UIColor greenColor];
        }
    }
}

@end
